<template>
  <card-container @refresh="refresh" :title="title">
    <ve-ring :colors="colorConfig" width="100%" height="100%" :extend="chartExtend" :data="statisticsData"
             :settings="chartSettings"></ve-ring>
  </card-container>
</template>

<script>
import {statisticsPageMixins} from "@/views/checkStatisticsPage/mixins/statisticsPageMixins";
import {statisticSource} from "@/api/checkPage/statistics";
import {isArr} from "@/utils/arrayUtil";

export default {
  mixins: [statisticsPageMixins],
  data() {
    const colorConfig = ['rgba(141, 82, 235, 1)', 'rgba(255, 147, 59, 1)', 'rgba(2, 242, 138, 1)',]
    return {
      title: '隐患来源统计',
      queryFun: statisticSource,
      colorConfig,
      statisticsData: {},
      chartSettings: {
        radius: [50, 70],
        offsetY: 300,
        dimension: '来源',
        metrics: '数量',
        center: ['20%', '50%'],
      },
      chartExtend: {
        itemStyle: (param) => {
          console.log(param)
        },

        series(ser) {
          return isArr(ser) ? ser.map((item, index) => {
            item.center = ['25%', '50%']
            return item
          }) : ser;
        },
        legend: {
          left: '48%',
          right: 0,
          top: '22%',
          bottom: 20,
        }
      },
    }
  },
  methods: {
    changeRowData(baseData) {
      let columns = ['来源', '数量'];
      let rows = [
        {
          '来源': '抽查',
          '数量': baseData.choucha
        },
        {
          '来源': '督查',
          '数量': baseData.ducha
        },
        {
          '来源': '自查',
          '数量': baseData.zicha
        },
      ]
      return {columns, rows}
    }
  }
}
</script>

<style scoped>

</style>
